home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_300
/
399_01
/
mined.h
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-03
|
14KB
|
491 lines
/* ==================================================================== *
* Mined.h *
* ==================================================================== */
#ifndef minedH
#define minedH
#ifdef __MSDOS__
#undef unix /* needed for djgcc? */
#define msdos
#define pc
# ifndef __TURBOC__
# define __GCC__
# undef msdos /* in this queer case, a more specific distinction */
# define unix /* has to be made everywhere according to the 'pc' flag */
# endif
#endif
#ifdef msdos
/* With Turbo-C, compile with memory model >= Compact */
/* #define conio doesn't work with current combined positioning/output method */
extern far * getenv ();
extern far * getcwd ();
extern void setdisk ();
# include <stdio.h>
# undef putchar
# include <fcntl.h>
# define FUNcmd '\000'
extern void sleep ();
extern void delay ();
extern void exit ();
#endif
#ifdef vms
# include <unixio.h>
# include <file.h> /* for the O_... attributes to open () */
# include <unixlib.h>
# undef putchar
# undef FALSE
# undef TRUE
# define CURSES
# define FUNcmd '\200'
#endif
#ifdef unix
/*#include <stdlib.h> */
# include <stdio.h>
# include <string.h>
# include <fcntl.h>
# include <unistd.h>
# undef putchar
# undef NULL
# undef EOF
# define FUNcmd '\200'
# ifndef sysV
extern char * getwd ();
# define getcwd(dirbuf, buflen) getwd (dirbuf)
# else
extern char * getcwd ();
# endif
extern void exit ();
extern char * getenv ();
extern int printf ();
extern int vfork ();
#ifdef __GCC__
extern int wait ();
#else
extern pid_t wait ();
#endif
extern int select ();
extern unsigned int sleep ();
extern unsigned int usleep ();
#endif /* unix */
typedef unsigned char uchar;
/*------------------------------------------------------------------------*/
extern void raw_mode ();
extern void clear_screen ();
extern void clear_eol ();
extern void scroll_forward ();
extern void scroll_reverse ();
extern void add_line (/* y */);
extern void delete_line (/* y */);
extern void move_cursor (/* x, y */);
extern void reverse_on ();
extern void reverse_off ();
extern void start_screen_mode ();
extern void end_screen_mode ();
extern void get_term ();
extern void getwinsize ();
#ifdef msdos
extern void set_video_lines ();
extern void set_textmode_height ();
extern void switch_textmode_height ();
extern void set_grafmode_height ();
extern void set_fontbank ();
extern void set_screen_mode ();
extern void resize_screen ();
#endif
extern int inputreadyafter ();
extern int readchar ();
extern int _readchar ();
extern int __readchar ();
extern int find_y_w_o_RD ();
extern int scratch_file ();
extern void suspendmyself ();
extern void catch_signals ();
extern int char_ready_within ();
extern int get_number ();
extern void display ();
extern void reset ();
extern void move_y ();
extern void move_to ();
extern void set_cursor_xy ();
extern void put_line ();
extern void move_address ();
extern int length_of ();
extern int text_length_of ();
extern int insert ();
extern void copy_string ();
extern int get_file ();
extern int get_line ();
extern void bad_write ();
extern void file_status ();
extern int find_x ();
extern void RDwin ();
extern void RD_y ();
extern void panicio ();
extern int panicwrite ();
extern int wrt_text ();
extern void set_font_height ();
extern void changetocode ();
extern uchar grave ();
extern uchar circumflex ();
extern uchar acute ();
extern uchar diaeresis ();
extern uchar tilde ();
extern uchar angstrom ();
/* aux: */
extern void delete_yank_file ();
extern void rd_bottom_line ();
extern void clear_wholeline ();
extern void clear_lastline ();
extern void (* keyproc) ();
extern void catch_interrupt ();
extern int make_number ();
/* from system: */
extern int write ();
extern int read ();
extern int access ();
extern int open ();
extern int close ();
extern int creat ();
extern int chdir ();
extern int system ();
extern int strcmp ();
extern int isatty ();
/*------------------------------------------------------------------------*/
/*
* Convert cnt to nearest tab position
*/
#define tab(cnt) (((cnt) + 8) & ~07)
#define is_tab(c) ((c) == '\t')
/*
* Word definitions
*/
#define white_space(c) ((c) == ' ' || (c) == '\t')
#define alpha(c) ((c) != ' ' && (c) != '\t' && (c) != '\n')
/* Set cursor at coordinates x, y */
#define set_cursor(nx, ny) move_cursor(nx, ny)
/* Screen size and display definitions. Coordinates start at 0, 0 */
#ifdef pc
# define maxYMAX 64
# define maxXMAX 132
#else
# define maxYMAX 126 /* 73 */
# define maxXMAX 279 /* 163 */
#endif
extern short YMAX;
extern short XMAX;
#define SCREENMAX (YMAX - 1) /* last line displayed (first is 0) */
#define XBREAK (XMAX) /* Shift line display at this column */
#define SHIFT_SIZE (tab (XMAX / 4 + 1)) /* Number of chars to shift */
#define maxLINE_LEN (maxXMAX + 1) /* max screen line length */
#define screen_BUFL (maxXMAX * maxYMAX) /* Size of I/O buffering */
#define MAX_CHARS 1024 /* max chars on one line of text */
/* LINE_START must be rounded up to the lowest SHIFT_SIZE */
#define LINE_START (((-MAX_CHARS - 1) / SHIFT_SIZE) * SHIFT_SIZE \
- SHIFT_SIZE)
#define LINE_END (MAX_CHARS + 1) /* Highest x-coordinate for line */
#define BLOCK_SIZE 1024
/* Return values of functions */
#define ERRORS -1
#define NO_LINE (ERRORS - 1) /* Must be < 0 */
#define FINE (ERRORS + 1)
#define NO_INPUT (ERRORS + 2)
#define STD_IN 0 /* Input file # */
#define STD_OUT 1 /* Terminal output file # */
#define STD_ERR 2
#define REPORT 1 /* Report change of lines on # lines */
#ifndef pc
# define O_BINARY 0
#endif
/*
* Common enum type for all flags used in mined.
*/
typedef enum {
/* General flags */
FALSE,
TRUE,
OFF,
ON,
/* yank_status and other */
NOT_VALID,
VALID,
/* Expression flags */
FORWARD,
REVERSE,
/* Yank flags */
SMALLER,
BIGGER,
SAME,
/* EMPTY, */
NO_DELETE,
DELETE,
READ,
WRITE
} FLAG;
/*
* The Line structure. Each line entry contains a pointer to the next line,
* a pointer to the previous line, a pointer to the text and an unsigned char
* telling at which offset of the line printing should start (usually 0).
*/
struct Line {
struct Line * next;
struct Line * prev;
char * text;
unsigned char shift_count;
};
typedef struct Line LINE;
/* Dummy line indicator */
#define DUMMY 0x80
#define DUMMY_MASK 0x7F
/* Expression definitions */
#define NO_MATCH 0
#define MATCH 1
#define REG_ERROR 2
#define BEGIN_LINE (2 * REG_ERROR)
#define END_LINE (2 * BEGIN_LINE)
/*
* For casting functions with int/void results
*/
typedef void (* voidfunc) ();
typedef uchar (* charfunc) ();
typedef int (* intfunc) ();
/*
* Determine multi-character prefix bytes (Chinese)
*/
#define multichar(c) ((uchar) c > '\177')
extern int inmultichar ();
/*
* The regex structure. Status can be any of 0, BEGIN_LINE or REG_ERROR. In
* the last case, the result.err_mess field is assigned. Start_ptr and end_ptr
* point to the match found. For more details see the documentation file.
*/
struct regex {
union {
char * err_mess;
int * expression;
} result;
char status;
char * start_ptr;
char * end_ptr;
};
typedef struct regex REGEX;
/* NULL definitions */
#define NIL_PTR ((char *) 0)
#define NIL_LINE ((LINE *) 0)
#define NIL_REG ((REGEX *) 0)
#define NIL_INT ((int *) 0)
/*
* Forward declarations
*/
extern int total_lines; /* Number of lines in file */
extern long total_chars; /* Number of characters in file */
extern LINE * header; /* Head of line list */
extern LINE * tail; /* Last line in line list */
extern LINE * top_line; /* First line of screen */
extern LINE * bot_line; /* Last line of screen */
extern LINE * cur_line; /* Current line in use */
extern char * cur_text; /* Pointer to char on current line in use */
extern int last_y; /* Last y of screen, usually SCREENMAX */
extern int x, y; /* x, y coordinates on screen */
extern FLAG modified; /* Set when file is modified */
extern FLAG viewonly; /* Set when view only mode is selected */
extern FLAG quit; /* Set when quit character is typed */
extern FLAG intr_char; /* Set when intr character is typed */
extern FLAG winchg; /* Set when the win